package me.sdevil507.activemq.delay;

import lombok.extern.slf4j.Slf4j;
import me.sdevil507.activemq.QueueName;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * 延迟消息消费者
 *
 * @author sdevil507
 */
@Component
@Slf4j
public class DelayCustomer {

    /**
     * 接收延迟消息
     * <p>
     * 开启最低5个线程同时处理
     *
     * @param msg 延迟消息
     */
    @JmsListener(destination = QueueName.DELAY, concurrency = "5-20")
    public void receiveMessage(String msg) {
        System.out.println(LocalDateTime.now() + ",msg:"+msg);
    }
}
